home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2000 Reader Awards / macformat-098.iso / MF Data / Behaviours / 00006_Script_fade < prev    next >
Encoding:
Text File  |  2000-11-01  |  1.8 KB  |  47 lines

  1.  
  2. property startBlend 
  3. property StartFadePoint 
  4. property EndFadePoint
  5.  
  6. on exitFrame me -- provides the trigger for the blend updates
  7.   sendSprite  (the spritenum of me, #blendit)
  8. end
  9.  
  10. on blendSprite which, what -- does the blending :)
  11.   set the blend of sprite which = what
  12.   updatestage
  13. end  
  14.  
  15. on blendit me 
  16.   set dv = abs((the locV of sprite the spriteNum of me) - the mousev)
  17.   set  dH = abs((the locH of sprite the spriteNum of me) - the mouseh)
  18.   set distance = sqrt( dV * dV + dH * dH ) 
  19.   if distance < EndFadePoint then
  20.     blendSprite the spriteNum of me,100 
  21.     exit
  22.   end if
  23.   if distance < StartFadePoint then
  24.     set percentage = (distance*100/StartFadePoint) 
  25.     set blendToValue =  (100-percentage)
  26.     if blendToValue < startBlend then set blendToValue =  startBlend 
  27.     blendSprite the spriteNum of me,blendToValue 
  28.   else
  29.     blendSprite the spriteNum of me,startBlend 
  30.   end if
  31.   updatestage
  32. end
  33. on getPropertyDescriptionList
  34.   set p_list = [¨
  35.                     #startBlend: [ #default:0, #format:#integer, #comment:"Initial Blend",#range: [#min:0,#Max:100]] ,¨
  36.                        #StartFadePoint: [ #default:100, #format:#integer, #comment:"Trigger Point", #range:[#min:0,#Max:1500]],¨
  37.                        #EndFadePoint: [ #default:0, #format:#integer, #comment:"End Trigger Point", #range:[#min:0,#Max:1500]] ¨
  38.                     ]
  39.   return p_list
  40. end
  41. on getBehaviorDescription
  42.   return  "Creates sprites that fade in and out (using the sprite blend property) depending how far they are from the mouse. " &return&return&¨
  43.                     "Try different inks for your sprites - different images require different settings. Also, there appears to be a bug in Director 6 that prevents sprites with a blend of 0 from being totally hidden. "
  44.   
  45. end
  46.  
  47.